<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="http://libs.baidu.com/jquery/1.8.0/jquery.min.js"></script>
</head>
<body>
    <input type="text" id="name" placeholder="name" value="pear">
    <input type="text" id="price" placeholder="price" value="5">
    <input type="text" id="num" placeholder="num" value="4">
    <button id="btn1">get</button>
    <button id="btn2">post</button>
    <script>
        $('#btn1').click(function() {
            $.ajax({
                url: 'http://localhost:3000/list',
                success(data) {
                    console.log(1, data);
                }
            })
        })

        $('#btn2').click(function() {
            let name = $('#name').val();
            let price = $('#price').val();
            let num = $('#num').val();

            $.ajax({
                url: 'http://localhost:3000/add',
                type: 'post',
                data: {name, price, num},
                success(data) {
                    console.log(2, data);
                }
            })
        })
    </script>
</body>
</html>